﻿Public Class ScriptInformation
    Private _author As String
    Private _licence As String
    Private _HelpUri As Uri
    Private _homepage As Uri
    Private _imageUri As Uri
    Private _title As String
    Private _version As Version
    Private _CintieFrameworkVersion As Version

    Private _baseFile As IO.FileInfo

    Public Sub New(ByVal ScriptFile As String)
        _baseFile = New IO.FileInfo(ScriptFile)

        Dim xDoc As XDocument = XDocument.Load(ScriptFile)

        Try
            _author = xDoc.<Script>.<ScriptInformation>.<Author>.Value
        Catch ex As Exception
            _author = ""
        End Try

        Try
            _licence = xDoc.<Script>.<ScriptInformation>.<Licence>.Value
        Catch ex As Exception
            _licence = ""
        End Try

        Try
            Dim __HelpUri As New Uri(xDoc.<Script>.<ScriptInformation>.<HelpUri>.Value, UriKind.RelativeOrAbsolute)
            _HelpUri = __HelpUri
        Catch ex As Exception

        End Try

        Try
            Dim __homepage As New Uri(xDoc.<Script>.<ScriptInformation>.<HomePage>.Value, UriKind.RelativeOrAbsolute)
            _homepage = __homepage
        Catch ex As Exception

        End Try

        Try
            _title = xDoc.<Script>.<ScriptInformation>.<Title>.Value
        Catch ex As Exception

        End Try

        _version = New Version
        Try
            _version = Version.Parse(xDoc.<Script>.<ScriptInformation>.<Version>.Value)
        Catch ex As Exception

        End Try

        _CintieFrameworkVersion = New Version
        Try
            _CintieFrameworkVersion = Version.Parse(xDoc.<Script>.<ScriptInformation>.<CintieFrameworkVersion>.Value)
        Catch ex As Exception

        End Try

        Try
            Dim StrImg As String = xDoc.<Script>.<ScriptInformation>.<ImageUri>.Value
            If StrImg.StartsWith("\") Then
                StrImg = String.Format("{0}{1}", _baseFile.Directory, StrImg)
            End If
            Dim __ImageUri As New Uri(StrImg, UriKind.RelativeOrAbsolute)
            _imageUri = __ImageUri
        Catch ex As Exception

        End Try
    End Sub

    Public Property Author As String
        Get
            Return _author
        End Get
        Set(ByVal value As String)
            _author = value
        End Set
    End Property

    Public Property Licence As String
        Get
            Return _licence
        End Get
        Set(ByVal value As String)
            _licence = value
        End Set
    End Property

    Public Property HelpUri As Uri
        Get
            Return _HelpUri
        End Get
        Set(ByVal value As Uri)
            _HelpUri = value
        End Set
    End Property

    Public Property HomePage As Uri
        Get
            Return _homepage
        End Get
        Set(ByVal value As Uri)
            _homepage = value
        End Set
    End Property

    Public Property ImageUri As Uri
        Get
            Return _imageUri
        End Get
        Set(ByVal value As Uri)
            _imageUri = value
        End Set
    End Property

    Public Property Title As String
        Get
            Return _title
        End Get
        Set(ByVal value As String)
            _title = value
        End Set
    End Property


    Public Property Version As Version
        Get
            Return _version
        End Get
        Set(ByVal value As Version)
            _version = value
        End Set
    End Property

    Public Property CintieFrameworkVersion As Version
        Get
            Return _CintieFrameworkVersion
        End Get
        Set(ByVal value As Version)
            _CintieFrameworkVersion = value
        End Set
    End Property

   
End Class
